module barrel_shift (
    input wire  [31:0]  data_in ,//输入数据
    input wire          dir     ,//位移方向 0：循环左移 1：循环右移
    input wire  [4 :0]  sh      ,//位移值，取值0~31
    output wire [31:0]  data_out //输出数据
);
assign   data_out = {32{dir }}&((data_in>>sh)|(data_in<<(32-sh)))
                  | {32{~dir}}&((data_in<<sh)|(data_in>>(32-sh)));

endmodule